package com.grj.model.user.convert;


import com.grj.model.user.dto.UserDTO;
import com.grj.model.user.entity.User;
import com.grj.model.user.vo.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author 14505
 */

@Mapper
public abstract class UserConvert {

    public static UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    @Mappings(value={
            @Mapping(source = "iddto",target = "idvo"),
            @Mapping(source = "username",target = "username")
    })
    public abstract UserVO dto2vo(UserDTO userDTO);

    @Mappings(value={
            @Mapping(source = "idvo",target = "iddto"),
            @Mapping(source = "username",target = "username")
    })
    public abstract UserDTO vo2dto(UserVO userVO);

    @Mappings(value={
            @Mapping(source = "id",target = "idvo"),
            @Mapping(source = "username",target = "username")
    })
    public abstract UserVO vo(User user);

    @Mappings(value={
            @Mapping(source = "id",target = "iddto"),
            @Mapping(source = "username",target = "username")
    })
    public abstract UserDTO dto(User user);
}
